package com.woniu.springbootrbac.service.impl;

import com.woniu.springbootrbac.dto.DeptDto;
import com.woniu.springbootrbac.entity.SysDept;
import com.woniu.springbootrbac.mapper.SysDeptMapper;
import com.woniu.springbootrbac.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private SysDeptMapper mapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        List list = mapper.selUser(id);
        if (list.size()>0){
            return 0;
        } else {
            return mapper.deleteByPrimaryKey(id);
        }
    }

    @Override
    public int insert(SysDept record) {
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(SysDept record) {
        return mapper.insertSelective(record);
    }

    @Override
    public SysDept selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysDept> selAll(DeptDto dept) {
        return mapper.selAll(dept);
    }

    @Override
    public int updateByPrimaryKeySelective(SysDept record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SysDept record) {
        return mapper.updateByPrimaryKey(record);
    }
}
